﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxWCFTest.aspx.cs" Inherits="BugSysSolution.WCFAjax.AjaxWCFTest" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Style/site.css" rel="stylesheet" />
    <script src="../Javascript/jquery-1.8.0.min.js"></script>
    <script src="../PageTemplate/Knockout.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" id="btnget" value="GetOne" />
            <input type="button" id="btngetall" value="GetAll" />
            <input type="button" id="btn3" value="GetJson" />
        </div>
    <div>
        <%--<table id="tab1" class="tab">
            <tr>
                <td>Id:</td>
                <td>Name:</td>
                <td>Age:</td>
            </tr>
            <tr>
                <td data-bind="text:perid"></td>
                <td data-bind="text:pername"></td>
                <td data-bind="text:perage"></td>
            </tr>
        </table>--%>
        <table id="tab2" class="tab" data-bind="foreach:person">
            <tr>
                <td data-bind="text:$data.id"></td>
                <td data-bind="text:$data.name"></td>
                <td data-bind="text:$data.age"></td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    $("#btnget").click(function () {
        $.getJSON("WcfAjax.svc/GetOne", {}, function (data) {
            data = data.d;
            var model = function () {
                this.perid = ko.observable(data.id);
                this.pername = ko.observable(data.name);
                this.perage = ko.observable(data.age);
            }
            ko.applyBindings(new model());
        });
    })

    $("#btngetall").click(function () {
        $.getJSON("WcfAjax.svc/GetAll", null, function (data) {
            var arr = data.d;

            var model = function () {
                this.person = ko.observableArray(arr);
            }

            ko.applyBindings(new model());
        });
    })

    //$("#btn3").click(function () {
        

    //    $.getJSON("http://mspspdev/webcoe/_vti_bin/lists.asmx", null, function (data) {
    //        var arr = data.d;

    //        var model = function () {
    //            this.person = ko.observableArray(arr);
    //        }

    //        ko.applyBindings(new model());
    //    });
    //})



    //javascript: function a() { var _a = $("head"); var _b = $("<meta http-equiv='X-UA-Compatible' content='IE=9' />"); _a.append(_b); alert(_a.children().length); } a();
    //javascript: javascript:function a() { var _a = $("#ctl00_Head1"); var _b = $("<meta http-equiv='X-UA-Compatible' content='IE=9' id='3' />"); _a.append(_b); alert(_b.attr("id"))} a();
    
    //<META http-equiv=X-UA-Compatible content=IE=8;requiresActiveX=true>
</script>